var t = require;
var e = module;
var o = exports;
var i, n = this && this.__extends || (i = function(t, e) {
    return (i = Object.setPrototypeOf || {
        __proto__: []
    }
    instanceof Array &&
    function(t, e) {
        t.__proto__ = e
    } ||
    function(t, e) {
        for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
    })(t, e)
},
function(t, e) {
    function o() {
        this.constructor = t
    }
    i(t, e),
    t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
}),
a = this && this.__decorate ||
function(t, e, o, i) {
    var n, a = arguments.length,
    r = a < 3 ? e: null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);
    else for (var s = t.length - 1; s >= 0; s--)(n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
    return a > 3 && r && Object.defineProperty(e, o, r),
    r
};
Object.defineProperty(o, "__esModule", {
    value: !0
});
var r = t("GameConstant"),
s = t("Util"),
l = t("Global"),
c = t("Boomerang"),
d = cc._decorator,
h = d.ccclass,
p = d.property,
u = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.node_pos = null,
        e.pfb_boom = null,
        e._gameControl = null,
        e._parent = null,
        e.isGameOver = !1,
        e.tagCollider = 0,
        e._damageNum = 0,
        e._carTag = 0,
        e.boom = null,
        e.isDamage = !0,
        e.bCanAttack = !0,
        e
    }
    return n(e, t),
    e.prototype.init = function(t, e, o, i, n, a) {
        this._gameControl = t,
        this._parent = e,
        this.tagCollider = o,
        this._damageNum = i,
        this._carTag = n,
        this._carTag == r.Collide_Car_Tag.Left ? (this.node.scaleX = 1, this.node.position = a) : (this.node.scaleX = -1, this.node.position = cc.v3( - a.x, a.y, a.z))
    },
    e.prototype.playAnimation = function() {
        this.attack()
    },
    e.prototype.attack = function() { ! this.bCanAttack || this.boom || this.isGameOver || (this._gameControl.playSound(this._gameControl._audioControl.boomerang), this.node.getChildByName("Boom").active = !1, this.createRocketItem())
    },
    e.prototype.back = function() {
        this.boom = null,
        this.node.getChildByName("Boom").active = !0,
        this.scheduleOnce(this.playAnimation, s.Util.attackSpeed(.5, this._carTag))
    },
    e.prototype.destroyBoom = function() {
        this.boom && this.boom.destroy()
    },
    e.prototype.onGameStart = function() {},
    e.prototype.onGameOver = function() {
        this.unschedule(this.attack),
        this.isGameOver = !0,
        this.destroyBoom()
    },
    e.prototype.onGameBoutReady = function() {
        this.node.active = !1,
        this.destroyBoom(),
        this.destroy()
    },
    e.prototype.onGameBoutStart = function() {
        var t = this;
        this.scheduleOnce(function() {
            t.bCanAttack = !0,
            t.playAnimation()
        },
        1)
    },
    e.prototype.onGameBoutOver = function() {
        this.unschedule(this.attack),
        this.isGameOver = !0
    },
    e.prototype.onCanAttack = function(t) {
        if (this.bCanAttack = t, t) {
            if (this.isGameOver) return;
            this.playAnimation()
        }
    },
    e.prototype.createRocketItem = function() {
        var t = this.node_pos.convertToWorldSpaceAR(cc.v3(0, 0, 0)),
        e = cc.find("Canvas").convertToNodeSpaceAR(t),
        o = this._parent.angle,
        i = 1;
        this._carTag == r.Collide_Car_Tag.Left ? i = this._gameControl._carLeftView.getScaleX() : this._carTag == r.Collide_Car_Tag.Right && (i = this._gameControl._carRightView.getScaleX());
        var n = s.Util.objectPool.getNodeFromNodePool(l.PoolKey.Boomerang, this.pfb_boom);
        this.boom = n,
        n.getComponent(c.default).initItem(this.tagCollider, this._carTag, i, e, o, this.node_pos, this),
        cc.find("Canvas").addChild(n)
    },
    e.prototype.getDamage = function() {
        return console.log("getDamage"),
        s.Util.vibrateMiddle(),
        this._gameControl.playSound(this._gameControl._audioControl.body_hit1),
        this.boom && (this.boom.getComponent(c.default).collider.enabled = !1),
        this._damageNum
    },
    a([p(cc.Node)], e.prototype, "node_pos", void 0),
    a([p(cc.Prefab)], e.prototype, "pfb_boom", void 0),
    a([h], e)
} (cc.Component);
o.default = u